package com.infocollect.project.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.infocollect.project.api.entity.TappActEntity;
import com.infocollect.project.api.mapper.TappActMapper;
import com.infocollect.project.api.service.ITappActService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (TappAct)表服务实现类
 *
 * @author makejava
 * @since 2019-12-25 10:32:26
 */
@Service("tappActService")
public class TappActServiceImpl extends ServiceImpl<TappActMapper, TappActEntity> implements ITappActService {


    @Override
    public List<TappActEntity> queryByPorcessId(Long fid) {
        QueryWrapper<TappActEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("fprocessid", fid);
        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param fid 主键
     * @return 实例对象
     */
    @Override
    public TappActEntity queryById(Long fid) {
        return baseMapper.selectById(fid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<TappActEntity> queryAllByLimit(int offset, int limit) {
        return this.baseMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tappAct 实例对象
     * @return 实例对象
     */
    @Override
    public TappActEntity insert(TappActEntity tappAct) {
        this.baseMapper.insert(tappAct);
        return tappAct;
    }

    /**
     * 修改数据
     *
     * @param tappAct 实例对象
     * @return 实例对象
     */
    @Override
    public TappActEntity update(TappActEntity tappAct) {
        baseMapper.updateById(tappAct);
        return this.queryById(tappAct.getFid());
    }

    /**
     * 通过主键删除数据
     *
     * @param fid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long fid) {
        return this.baseMapper.deleteById(fid) > 0;
    }

    /**
     * 根据节点Id和流程模板ID查找当前节点
     *
     * @return 对象列表
     * @menu 根据实体对象是否有值 进行查询
     */
    @Override
    public List<TappActEntity> queryByNodeIdAndProcid(String actchartid, Long procid) {
        QueryWrapper<TappActEntity> queryWrapper = new QueryWrapper<TappActEntity>();
        queryWrapper.eq("Factchartid", actchartid).eq("fprocessid", procid);
        return baseMapper.selectList(queryWrapper);
    }

    /**
     * 查询多条数据
     *
     * @return 对象列表
     * @menu 根据实体对象是否有值 进行查询
     */
    @Override
    public List<TappActEntity> queryAll(TappActEntity entity) {
        return baseMapper.queryAll(entity);
    }

    @Override
    public List<TappActEntity> gettestList() {
        return baseMapper.selectList(null);

    }
}